package com.xmim.server.examples;

import com.xmim.core.container.ServerContainer;
import com.xmim.fulcrum.FulcrumDiscover;
import com.xmim.fulcrum.FulcrumUtil;
import com.xmim.fulcrum.session.FulcrumSession;
import com.xmim.fulcrum.node.FulcrumServiceNode;
import com.xmim.fulcrum.session.AbstractFulcrumSessionManager;
import io.netty.channel.ChannelHandler;

public class NettyFulcrumSessionManager extends AbstractFulcrumSessionManager<String, ChannelHandler> {

    public NettyFulcrumSessionManager(FulcrumDiscover parent) {
        super(parent.getFactory(), parent);
    }

    @Override
    protected FulcrumSession createSession(ServerContainer parent, FulcrumServiceNode localNode) {
        NettyFulcrumSession fulcrumSession = new NettyFulcrumSession(getFactory(), parent, localNode);
        FulcrumUtil.addHandle(parent, fulcrumSession);
        return fulcrumSession;
    }


    @Override
    public boolean checkHandler(Class<?> handler) {
        return ChannelHandler.class.isAssignableFrom(handler.getClass());
    }

}
